import java.util.Scanner;
// We have imported the necessary tool classes.
// If you need to import additional packages or classes, please import here.
public class Main {
    public static void main(String[] args) {
    // please define the JAVA input here. For example: Scanner s = new Scanner(System.in);
    // please finish the function body here.
    // please define the JAVA output here. For example: System.out.println(s.nextInt());
    Scanner scanner = new Scanner(System.in);
    int x = scanner.nextInt();   // 总价
    int m = scanner.nextInt();  // 商品的数量
    int[] val = new int[m];
    for (int i = 0; i < m; i++) {
    val[i] = scanner.nextInt();
}

int[][] dp = new int[m+1][x+1];
dp[0][0] = 1;

for (int i = 0; i < m; i++) {
    for (int j = 0; j <= x; j++) {
        dp[i + 1][j] = dp[i][j];
        if (j >= val[i]) {
            if (dp[i][j - val[i]] > 0) {
                dp[i + 1][j]++;
            }
        }
    }
}
if (dp[m][x] == 0) {
    System.out.println("-1");
}else {
    System.out.println(dp[m][x]);
}
}
}

///////////////

public class Main {
    private static int res = 0;
    public static void main(String[] args) {
    // please define the JAVA input here. For example: Scanner s = new Scanner(System.in);
    // please finish the function body here.
    // please define the JAVA output here. For example: System.out.println(s.nextInt());
    Scanner scanner = new Scanner(System.in);
    int target = scanner.nextInt();
    int n = scanner.nextInt();
    int[] nums = new int[n];
    for (int i = 0; i< n; i++) {
    nums[i] = scanner.nextInt();
}
Arrays.sort(nums);
int count = 0;
for (int  i = 2; i < nums.length; i++) {
    res = 0;
    count += backtrack(nums, i, 0, target);
}
if (count == 0) System.out.println(-1);
else System.out.println(count);
}
}
// 回溯算法
public static int backtrack(int[] nums, int n , int start, int target) {
    int len = nums.length;
    if (n < 2 || len < n) return res;
    if (n == 2) {
        int lo = start;
        int hi = len -1;
        while (lo < hi) {
            int sum = nums[lo] + nums[hi];
            if (sum < target) {
                lo++;
            }else if (sum > target) {
                hi--;
            }else {
                res++;
                lo++;
                hi--;
            }
        }
    }else {
        for (int i = start; i< len; i++){
            backtrack(nums, n-1, i+1, target - nums[i]);
        }
    }
    return res;
}